package com.example.demo.service.impl;

import com.example.demo.common.response.ResponsePage;
import com.example.demo.entity.Pet;
import com.example.demo.entity.VO.Announcement;
import com.example.demo.entity.param.AnnouncementParam;
import com.example.demo.entity.param.PetParam;
import com.example.demo.mapper.AdminMapper;
import com.example.demo.service.AdminService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;


@Service
public class AdminServiceImpl implements AdminService {
    @Resource
    private AdminMapper adminMapper;

    @Override
    public void addPet(Pet pet) {

    }

    @Override
    public void updatePet(Pet pet) {

    }

    @Override
    public Pet getPetById(Long id) {
        return null;
    }

    @Override
    public ResponsePage<Pet> getPetsList(PetParam petParam) {
        PageHelper.startPage(petParam.getPageNum(), petParam.getPageSize());
        //写查询逻辑，然后用下面这行
//        return ResponsePage.restPage(new PageInfo<>(petList));
        return null;
    }

    @Override
    public ResponsePage<Announcement> getAnnouncementList(AnnouncementParam announcementParam) {
        PageHelper.startPage(announcementParam.getPageNum(), announcementParam.getPageSize());
       List<Announcement> announcements = adminMapper.getAnnouncementList(announcementParam);
        return ResponsePage.restPage(new PageInfo<>(announcements));
    }

    @Override
    public void editAnnouncementList(Announcement announcement) {
        adminMapper.editAnnouncementList(announcement);
    }

    @Override
    public void addAnnouncementList(Announcement announcement) {
        adminMapper.addAnnouncementList(announcement);
    }
}
